@extends("/paging_template",title="仓库产品列表")
@import com.mgfireworks.mgplatform.mgadmin.stock.model.*
@import com.mgfireworks.mgplatform.mgadmin.constants.*
@import com.mgfireworks.mgplatform.mgadmin.user.model.*
@args List<StockDetail> stockDetailList, User currentUser
<s_panel>
	<s_input name="productId" text="产品编号" value="@val("productId")"></s_input>
	<s_input name="quantity" text="库存数" value="@val("quantity")"></s_input>

	<s_select name="outOfStock" text="是否缺货" deftext="所有" value="@val("outOfStock")">
	@for(BooleanEnum b : BooleanEnum.values()){
		<option value="@b.value()">@b.getPhrase()</option>
	}
	</s_select>
	<s_select name="online" text="是否上架" deftext="所有" value="@val("online")">
    @for(BooleanEnum b : BooleanEnum.values()){
        <option value="@b.value()">@b.getPhrase()</option>
    }
    </s_select>
    @if(currentUser.getOrg().getOrgType()==OrgType.FACTORY.value()){
    <s_buttons slot="button">
        <s_button type="query" col="5"></s_button>
        <s_button type="link" col="7" icon="fa-plus" href="@url("initStockProductList.html")">库存初始</s_button>
    </s_buttons>
    }else{
    <s_buttons slot="button" cols="1">
        <s_button type="query"></s_button>
    </s_buttons>
    }
</s_panel>


<div class="row">
	@if(stockDetailList){
	@{int i=0;}
	@for(StockDetail s : stockDetailList){
    <div class="product-item js-partial-form col col-sm-12 col-md-12 col-xs-12 col-lg-4">
        <input type="hidden" name="stockId" value="@s.getStockId()"/>
        <div class="thumbnail" style="height: auto;">
            <a href="?">
                <img src="@url(s.getMainImg())" alt="@s.getProductName()">
            </a>
            <div class="caption">
                <div class="pi-info">
                    <div class="pi-buttons">
                    @if(currentUser.getOrg().getOrgType()==OrgType.FACTORY.value()){
                        <a href="@url("edit.html?stockId=")@s.getStockId()" class="btn btn-lg btn-primary"><i class="fa fa-pencil"></i>修改</a>
                        <a href="@url("del.json")" class="btn btn-lg btn-default js-json-post" confirm="确定要删除？" result="reload"><i class="fa fa-times"></i>删除</a>
                    }else{
                        <a href="@url("underline.json")" class="btn btn-warning @if(s.getOnline()==0){disabled} js-json-post" result="reload"><i class="fa fa-arrow-down"></i>下架</a>
                        <a href="@url("online.json")" class="btn btn-success @if(s.getOnline()==1){disabled} js-json-post" result="reload"><i class="fa fa-arrow-up"></i>上架</a>
                        <a href="#jsDialogChangePrice" data-toggle="modal" class="btn btn-primary @if(s.getOnline()==1){disabled}"><i class="fa fa-edit"></i>调价</a>
                    }
                    </div>
                    <h3>@s.getProductName()</h3>
                    <p>类别：@s.getCateName()，品牌：@s.getBandName()</p>
                    <p>销售级别：@s.getSellLevelName()
                        @if(s.getOnline()==1){
                        <span class="badge bg-green">已上架</span>
                        }else{
                        <span class="badge bg-red">已下架</span>
                        }
                    </p>
                    <input type="hidden" name="price" value="@s.getPrice()"/>
                    <p>库存：<span class="badge bg-blue">@s.getQuantity()</span> 价格：<span class="badge bg-blue">@s.getPrice()</span>元</p>
                </div>
            </div>
        </div>
    </div>
	}}else{
    <div><i class="fa fa-exclamation-circle"></i>暂无库存产品</div>
    }
</div>


<div id="jsDialogChangePrice" class="modal fade" tabindex="-1">
    <div class="modal-dialog js-partial-form">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">
                    <span>&times;</span></button>
                <h4 class="modal-title">价格调整</h4>
            </div>
            <div class="modal-body">
                <div class="row main-form form-horizontal form-label-left">
                    <input type="hidden" name="stockId" value="{stockId}"/>
                    <f_input name="price1" text="原价格" value="{price}" readonly="readonly"></f_input>
                    <f_input name="price" text="新价格" value="{price}"></f_input>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <a href="@url("changePrice.json")" result="reload" class="btn btn-primary js-json-post">保存</a>
            </div>
        </div>
    </div>
</div>